<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>分类列表</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="css/bootstrap.css" rel="stylesheet">
<!-- 
<style type="text/css">
	body {background: rgb(254,238,189);}
	table {font-family: 宋体; font-size: 11pt; border-color: rgb(78,78,78);  width: 60%;}
	#th {background: rgb(78,78,78);}
</style>
-->
  </head>
  
  <body>
    <h2 style="text-align: center;">浏览热点列表</h2>
    
    <table class="table table-bordered table-striped">
    	<tr id="th" bordercolor="rgb(78,78,78)">
    		<th>种子名称</th>
    		<th>热点量</th>
    	</tr>
    <c:forEach items="${pb.beanList}" var="seed" >
    	<tr bordercolor="rgb(78,78,78)">
    		<td>${seed.sname}</td>
    		<td>${seed.overNumber}</td>
    	</tr>
    	
   </c:forEach>
    </table>
    
    <div class="container">
    	<div class="row">
    		<nav class="col-md-offset-4">
                <ul class="pagination">
                             第${pb.pc }页/共${pb.tp }页
                     <c:if test="${pb.pc>1 }">
                    <li><a href="<c:url value='/AdminSeedServlet?method=overWatch&pc=${pb.pc+1 }'/>">&laquo;</a></li>
                       </c:if>       
                    <li class="active"><a  href="<c:url value='/AdminSeedServlet?method=overWatch&pc=1'/>">首页</a></li>
                    <c:if test="${pb.pc>1 }">
                    <li><a href="<c:url value='/AdminSeedServlet?method=overWatch&pc=${pb.pc-1 }'/>">上一页</a></li>
                    
                    </c:if>
                    <%-- 计算begin、end --%>
<c:choose>
	<%-- 如果总页数不足10页，那么把所有的页数都显示出来！ --%>
	<c:when test="${pb.tp <= 10 }">
		<c:set var="begin" value="1" />
		<c:set var="end" value="${pb.tp }" />
	</c:when>
	<c:otherwise>
		<%-- 当总页数>10时，通过公式计算出begin和end --%>
		<c:set var="begin" value="${pb.pc-5 }" />
		<c:set var="end" value="${pb.pc+4 }" />	
		<%-- 头溢出 --%>
		<c:if test="${begin < 1 }">
			<c:set var="begin" value="1" />
			<c:set var="end" value="10" />
		</c:if>	
		<%-- 尾溢出 --%>
		<c:if test="${end > pb.tp }">
			<c:set var="begin" value="${pb.tp - 9 }" />
			<c:set var="end" value="${pb.tp }" />
		</c:if>	
	</c:otherwise>
</c:choose>
<%-- 循环遍历页码列表 --%>
<c:forEach var="i" begin="${begin }" end="${end }">
	
	<c:choose>
	<c:when test="${i eq pb.pc }">
	[${i }]
	</c:when>
	<c:otherwise>
	<a href="<c:url value='/AdminSeedServlet?method=overWatch&pc=${i }'/>">[${i }]</a>
	</c:otherwise>
	</c:choose>
</c:forEach>
                    <c:if test="${pb.pc<pb.tp }">
                    <li><a href="<c:url value='/AdminSeedServlet?method=overWatch&pc=${pb.pc+1 }'/>">下一页</a></li>
                     </c:if>
                    <li><a href="<c:url value='/AdminSeedServlet?method=overWatch&pc=${pb.tp}'/>">尾页</a></li>
                     <c:if test="${pb.pc<pb.tp }">
                    <li><a href="<c:url value='/AdminSeedServlet?method=overWatch&pc=${pb.pc+1 }'/>">&raquo;</a></li>
                    </c:if>
                </ul>
            </nav>
    	</div>
    </div>
   
  </body>
</html>
